﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<nelech.Models.DBModel.Munach>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	CreateMunach
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
   
<script src="../../Scripts/tinymce/jscripts/tiny_mce/tiny_mce.js" type="text/javascript"></script>
 <script type="text/javascript">
        function myCustomInitInstance(inst) {
            inst.setContent(document.getElementsByName('description').item(0).value);
        }

        tinyMCE.init({ theme: "advanced",
            mode: "exact",
            elements: "mce",
            plugins: "fullpage,paste,table,contextmenu",
            theme_advanced_buttons3_add: "fullpage,pastetext,pasteword,selectall",
            paste_remove_styles: false,
            paste_remove_styles_if_webkit: false,
            paste_remove_spans: false,
            paste_use_dialog: true,
            paste_auto_cleanup_on_paste: true,
            paste_convert_middot_lists: false,
            paste_unindented_list_class: "unindentedList",
            paste_convert_headers_to_strong: true,
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            init_instance_callback: "myCustomInitInstance",
            content_css: "/Content/tinymce.css"
        });

        function SerializeMCE() {
            var html = tinyMCE.activeEditor.serializer.serialize(tinyMCE.activeEditor.dom.select('body')[0]);
            document.getElementsByName('description').item(0).value = html;
        }

    </script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
  <% var db = new nelech.Models.DBModel.nelechDBEntities(); %>
    <h2>צור \ הוסף מונח</h2>

      <%= Html.ValidationSummary() %>
    <% using (Html.BeginForm(this.Model == null ? "CreateMunach" : "EditMunach", "Admin", FormMethod.Post, new { enctype = "multipart/form-data", onsubmit = "SerializeMCE()" }))
       {%>


        <fieldset>
            <legend>שדות:</legend>
            <input type="hidden" name="description" value="<%= Html.Encode(Model == null ? string.Empty : this.Model.description) %>" />
        <%
            if (Model != null)
            {
        %>
        <input type="hidden" name="id" value="<%= Model.id %>" />
        <input type="hidden" name="publish" value="1" />
        <%
            }
        %>

            <p>
            <label for="name">שם המונח:</label>
              
               
                 <%= Html.TextBox("name", this.Model == null || this.Model.name == null ? string.Empty : this.Model.name.ToString())%>
         <%= Html.ValidationMessage("name", "*") %>
           </p>  <div>
            <%= Html.TextArea("mce", new {rows="25", cols="80", id="mce"})%>
        </div>           
          
               <%
                IEnumerator<nelech.Models.DBModel.Image> enm = null;
                if (Model != null)
                {
                    enm = Model.Image.GetEnumerator();
                }
                for (int i = 1; i < 3; i++)
                {
            %>
            <p>
                <%
                    if (enm != null && enm.MoveNext())
                    {
                %>
                <label for="imagePath<%= i %>">
                    <%= enm.Current.text %>:
                </label>
                <br />
                <img class="thumbs" src="<%= enm.Current.path %>" />
                <a href="/Admin/RemoveImage/<%= enm.Current.id %>">מחק</a>
                <%
                    }
                    else
                    {
                %>
                <label for="imagePath<%= i %>">
                    תמונה:
                </label>
                <input type="file" name="imagePath<%= i %>" size="40" /><br />
                <label for="imageLabel<%= i %>">
                    כיתוב:</label>
                <input type="text" name="imageLabel<%= i %>" size="40" />
                <%
                    }
                %>
            </p>
            <%
                }
            %>
           <p>
                <input type="submit" value="שמור" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%=Html.ActionLink("חזור לרשימה", "ListMunach") %>
    </div>

</asp:Content>


